package com.safe.first.application.demo;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.UnknownHostException;

/**
 * @author Mickey
 * @since 2022/6/16
 **/
public class ClientSocket {

    public static void main(String[] args) {
        try {

            Socket socket = new Socket("127.0.0.1", 9999);

            BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));

            String str = "你好，这是我的第一个socket";

            bufferedWriter.write(str);

            bufferedWriter.flush();

            //关闭socket的输出流

//            socket.shutdownOutput();


        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
